
	Tesla.fn.load = function(action, param, container, target) {
		emit(this.BEFORE_LOAD);
		require.async(this.resolveScriptUrl(action), function(controller) {
			container =  (container || $("#" + $ts.DEFAULT_CONTAINER_ID));

			var config 	= new ConfigHandler(controller, action, param),
				handler = new ActionHandler(config, param, container, target),
				render 	= function() {
					try {
						if (typeof (config.handle) === "undefined") {
							handler.render();
						} else {
							config.handle.call(controller, handler);
						}
					} catch(e){
						emit($ts.ERROR, e);
					}
				};

			if (config.service && config.service.length > 0) {
				$ts.ajaxJSON(config.service, config.method, handler.param).done(function(result) {
					handler.model = result;
					render();
				});
			} else {
				render();
			}
			
			container.show();
		});
	};

	Tesla.fn.submit = function(action) {
		var _e 		= getEvent(),
			_form 	= $(_e.currentTarget).closest("form"),
			_data 	= {},
			_arr 	= _form.formToArray();

		_e.preventDefault();
		
		if (action.indexOf(".") < 0) {
			action = _form.closest(PAGE_SELECTOR).data("controller") + "." + action;
		}

		for (var i = 0, item; (item = _arr[i]) != null; i++) {
			if (item.type === "checkbox") {
				if (!_data[item.name]) {
					_data[item.name] = [];
				}
				_data[item.name].push(item.value);
			} else {
				_data[item.name] = item.value;
			}
		}

		this.load(action, _data, undefined, _e);
	};

	Tesla.fn.call = function(action, param) {
		var _target 	= $(getEvent().currentTarget),
			_this 		= this,
			_container 	= _target.closest(PAGE_SELECTOR);
		
		if (!_container.length) {
			_container = $("#" + this.DEFAULT_CONTAINER_ID);
		}
		
		if (action.indexOf(".") < 0) {
			action = _container.data("controller") + "." + action;
		}
		
		this.getAction(action).done(function (controller) {
			var _actionName = _this.getActionName(action),
				_handle = controller[_actionName];
			
			if (_handle) {
				try {
					_handle.call(controller, _target, _container, param);
				} catch(e){
					emit($ts.ERROR, e);
				}
			}
		});
	};

	Tesla.fn.link = function(action, param) {
		var _target = $(getEvent().currentTarget);
		
		if (action.indexOf(".") < 0) {
			action = _target.closest(PAGE_SELECTOR).data("controller") + "." + action;
		}
		
		this.load(action, param, _target.closest(PAGE_SELECTOR));
	};

	Tesla.fn.compile = function(html, data) {
		var template = undefined;
		try {
			template = juicer(html, data);
		} catch(e){
			emit($ts.ERROR, e);
		}
		return $(template);
	};